<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>基础信息设置</title>
    <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css" />
    <link rel="stylesheet" href="/static/assets/module/admin.css?v=312" />
    <style>
        .layui-form-item {
            margin-bottom: 25px;
        }

        label .layui-icon {
            font-size: 14px;
            color: #666;
        }
    </style>
</head>

<body>
    <!-- 正文开始 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <form class="layui-form" style="max-width: 700px;margin: 40px auto;">
                    <input type="hidden" name="id" placeholder="" class="layui-input"
                           lay-verType="tips" lay-verify="required" value="{$info['Id']}" required />

                    <div class="layui-form-item">
                        <label class="layui-form-label">Token:</label>
                        <div class="layui-input-block">
                            <input type="text" name="token" placeholder="" class="layui-input"
                                   lay-verType="tips" lay-verify="required" value="{$info['token']}" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-filter="formSubmitBas" lay-submit>&emsp;提交&emsp;</button>
                            <button type="reset" class="layui-btn layui-btn-primary">&emsp;重置&emsp;</button>
                        </div>
                    </div>
                </form>
                <hr>
                <fieldset class="layui-elem-field">
                    <legend>添加题库接口</legend>
                    <div class="layui-field-box">
                        网址：[HOST]/api</br>
                        数据：type=[分类id]&title=[试题标题]&option=[选项内容]&answer=[答案]&price=[价格]<br>
                        返回：1=成功|0=失败 <br>
                        注意：程序不会进行是否已存在的检测，因题库越来越多，不断检索太消耗资源。
                    </div>
                </fieldset>
            </div>
        </div>
    </div>

    <!-- js部分 -->
    <script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
    <script type="text/javascript" src="/static/assets/js/common.js?v=312"></script>
    <script>
        layui.use(['layer', 'form', 'element','laydate'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            var element = layui.element;
            // 监听表单提交
            form.on('submit(formSubmitBas)', function (data) {
                $.ajax({
                    type: "POST",
                    url: "{:url('admin/main/api')}",
                    data: data.field,
                    dataType: "json",
                    success: function (data) {
                        if (data.code == 0) {
                            layer.alert(data.msg,{
                                end:function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                }
                                }
                            );
                        } else {
                            layer.alert(data.msg);
                        }
                    },
                    error: function (data) {
                        alert("请求失败");
                    }
                });

                return false;
            });

        });
    </script>
</body>

</html>